/*     */ package eos.moe.dragoncore;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.color.ColorSpace;
/*     */ import java.awt.image.BufferedImage;
/*     */ import java.awt.image.ColorModel;
/*     */ import java.awt.image.ImageObserver;
/*     */ import java.awt.image.Raster;
/*     */ import java.awt.image.WritableRaster;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import java.nio.ByteBuffer;
/*     */ import java.util.Hashtable;
/*     */ 
/*     */ public class vj {
/*  15 */   private static final ColorModel l = new ComponentColorModel(
/*  16 */       ColorSpace.getInstance(1000), new int[] { 8, 8, 8, 8 }, true, false, 3, 0);
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*  24 */   private static final ColorModel t = new ComponentColorModel(
/*  25 */       ColorSpace.getInstance(1000), new int[] { 8, 8, 8, 0 }, false, false, 1, 0);
/*     */ 
/*     */   
/*     */   private int d;
/*     */ 
/*     */   
/*     */   private int z;
/*     */ 
/*     */   
/*     */   private int i;
/*     */ 
/*     */   
/*     */   private int w;
/*     */ 
/*     */   
/*     */   private int q;
/*     */ 
/*     */   
/*     */   private boolean g = true;
/*     */ 
/*     */   
/*     */   public int y() {
/*  47 */     return this.d;
/*     */   }
/*     */ 
/*     */   
/*     */   public int t() {
/*  52 */     return this.z;
/*     */   }
/*     */ 
/*     */   
/*     */   public int h() {
/*  57 */     return this.q;
/*     */   }
/*     */ 
/*     */   
/*     */   public int z() {
/*  62 */     return this.w;
/*     */   }
/*     */ 
/*     */   
/*     */   public int v() {
/*  67 */     return this.i;
/*     */   }
/*     */ 
/*     */   
/*     */   public ByteBuffer v(InputStream inputStream) throws IOException {
/*  72 */     return v(inputStream, true, null);
/*     */   }
/*     */   
/*     */   public ByteBuffer v(InputStream inputStream, boolean bool, int[] arrayOfInt) throws IOException {
/*  76 */     return v(inputStream, bool, false, arrayOfInt);
/*     */   }
/*     */   
/*     */   public ByteBuffer v(InputStream inputStream, boolean bool1, boolean bool2, int[] arrayOfInt) throws IOException {
/*  80 */     if (arrayOfInt != null) {
/*  81 */       bool2 = true;
/*     */     }
/*     */     
/*  84 */     BufferedImage bufferedImage = ImageIO.read(inputStream);
/*  85 */     return v(bufferedImage, bool1, bool2, arrayOfInt);
/*     */   }
/*     */   public ByteBuffer v(BufferedImage bufferedImage, boolean bool1, boolean bool2, int[] arrayOfInt) {
/*     */     BufferedImage bufferedImage1;
/*  89 */     ByteBuffer byteBuffer = null;
/*     */ 
/*     */ 
/*     */     
/*  93 */     int i = 2;
/*  94 */     int j = 2;
/*     */ 
/*     */ 
/*     */ 
/*     */     
/*  99 */     while (i < bufferedImage.getWidth()) {
/* 100 */       i *= 2;
/*     */     }
/* 102 */     while (j < bufferedImage.getHeight()) {
/* 103 */       j *= 2;
/*     */     }
/*     */     
/* 106 */     this.i = bufferedImage.getWidth();
/* 107 */     this.z = bufferedImage.getHeight();
/* 108 */     this.q = j;
/* 109 */     this.w = i;
/*     */ 
/*     */ 
/*     */     
/* 113 */     boolean bool = (bufferedImage.getColorModel().hasAlpha() || bool2);
/*     */     
/* 115 */     if (bool) {
/* 116 */       this.d = 32;
/* 117 */       WritableRaster writableRaster = Raster.createInterleavedRaster(0, i, j, 4, null);
/* 118 */       bufferedImage1 = new BufferedImage(l, writableRaster, false, new Hashtable<>());
/*     */     } else {
/* 120 */       this.d = 24;
/* 121 */       WritableRaster writableRaster = Raster.createInterleavedRaster(0, i, j, 3, null);
/* 122 */       bufferedImage1 = new BufferedImage(t, writableRaster, false, new Hashtable<>());
/*     */     } 
/*     */ 
/*     */     
/* 126 */     Graphics2D graphics2D = (Graphics2D)bufferedImage1.getGraphics();
/*     */ 
/*     */     
/* 129 */     if (bool) {
/* 130 */       graphics2D.setColor(new Color(0.0F, 0.0F, 0.0F, 0.0F));
/* 131 */       graphics2D.fillRect(0, 0, i, j);
/*     */     } 
/*     */     
/* 134 */     if (bool1) {
/* 135 */       graphics2D.scale(1.0D, -1.0D);
/* 136 */       graphics2D.drawImage(bufferedImage, 0, -this.z, (ImageObserver)null);
/*     */     } else {
/* 138 */       graphics2D.drawImage(bufferedImage, 0, 0, (ImageObserver)null);
/*     */     } 
/*     */     
/* 141 */     if (this.g) {
/* 142 */       if (this.z < j - 1) {
/* 143 */         v(bufferedImage1, 0, 0, this.i, 1, 0, j - 1);
/* 144 */         v(bufferedImage1, 0, this.z - 1, this.i, 1, 0, 1);
/*     */       } 
/* 146 */       if (this.i < i - 1) {
/* 147 */         v(bufferedImage1, 0, 0, 1, this.z, i - 1, 0);
/* 148 */         v(bufferedImage1, this.i - 1, 0, 1, this.z, 1, 0);
/*     */       } 
/*     */     } 
/*     */ 
/*     */ 
/*     */     
/* 154 */     byte[] arrayOfByte = ((DataBufferByte)bufferedImage1.getRaster().getDataBuffer()).getData();
/*     */     
/* 156 */     if (arrayOfInt != null) {
/* 157 */       for (int k = 0; k < arrayOfByte.length; k += 4) {
/* 158 */         boolean bool3 = true;
/* 159 */         for (int m = 0; m < 3; m++) {
/* 160 */           int n = (arrayOfByte[k + m] < 0) ? (256 + arrayOfByte[k + m]) : arrayOfByte[k + m];
/* 161 */           if (n != arrayOfInt[m]) {
/* 162 */             bool3 = false;
/*     */           }
/*     */         } 
/*     */         
/* 166 */         if (bool3) {
/* 167 */           arrayOfByte[k + 3] = 0;
/*     */         }
/*     */       } 
/*     */     }
/*     */     
/* 172 */     byteBuffer = ByteBuffer.allocateDirect(arrayOfByte.length);
/* 173 */     byteBuffer.order(ByteOrder.nativeOrder());
/* 174 */     byteBuffer.put(arrayOfByte, 0, arrayOfByte.length);
/* 175 */     byteBuffer.flip();
/* 176 */     graphics2D.dispose();
/*     */     
/* 178 */     return byteBuffer;
/*     */   }
/*     */   
/*     */   public ByteBuffer v() {
/* 182 */     throw new RuntimeException("ImageIOImageData doesn't store it's image.");
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public void v(boolean bool) {
/* 204 */     this.g = bool;
/*     */   }
/*     */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\eos\moe\dragoncore\vj.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */